package com.backend.agtmanaview.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.backend.common.annotation.Log;
import com.backend.common.core.controller.BaseController;
import com.backend.common.core.domain.AjaxResult;
import com.backend.common.enums.BusinessType;
import com.backend.agtmanaview.domain.AgtManaView;
import com.backend.agtmanaview.service.IAgtManaViewService;
import com.backend.common.utils.poi.ExcelUtil;
import com.backend.common.core.page.TableDataInfo;

/**
 * 租赁合同管理Controller
 * 
 * @author fusi
 * @date 2024-10-13
 */
@RestController
@RequestMapping("/agtmanaview/agtmanaview")
public class AgtManaViewController extends BaseController
{
    @Autowired
    private IAgtManaViewService agtManaViewService;

    /**
     * 查询租赁合同管理列表
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:list')")
    @GetMapping("/list")
    public TableDataInfo list(AgtManaView agtManaView)
    {
        startPage();
        List<AgtManaView> list = agtManaViewService.selectAgtManaViewList(agtManaView);
        return getDataTable(list);
    }

    /**
     * 导出租赁合同管理列表
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:export')")
    @Log(title = "租赁合同管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AgtManaView agtManaView)
    {
        List<AgtManaView> list = agtManaViewService.selectAgtManaViewList(agtManaView);
        ExcelUtil<AgtManaView> util = new ExcelUtil<AgtManaView>(AgtManaView.class);
        util.exportExcel(response, list, "租赁合同管理数据");
    }

    /**
     * 获取租赁合同管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:query')")
    @GetMapping(value = "/{leaseAgreementId}")
    public AjaxResult getInfo(@PathVariable("leaseAgreementId") Long leaseAgreementId)
    {
        return success(agtManaViewService.selectAgtManaViewByLeaseAgreementId(leaseAgreementId));
    }

    /**
     * 新增租赁合同管理
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:add')")
    @Log(title = "租赁合同管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AgtManaView agtManaView)
    {
        return toAjax(agtManaViewService.insertAgtManaView(agtManaView));
    }

    /**
     * 修改租赁合同管理
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:edit')")
    @Log(title = "租赁合同管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AgtManaView agtManaView)
    {
        return toAjax(agtManaViewService.updateAgtManaView(agtManaView));
    }

    /**
     * 删除租赁合同管理
     */
    @PreAuthorize("@ss.hasPermi('agtmanaview:agtmanaview:remove')")
    @Log(title = "租赁合同管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leaseAgreementIds}")
    public AjaxResult remove(@PathVariable Long[] leaseAgreementIds)
    {
        return toAjax(agtManaViewService.deleteAgtManaViewByLeaseAgreementIds(leaseAgreementIds));
    }
}
